<!DOCTYPE html>
<html>
   <head>
      <meta charset="utf-8" />
      <title>Descending opacity using css() - jQuery in Action, 3rd edition</title>
      <link rel="stylesheet" href="../css/main.css"/>
      <style>
         div
         {
            display: inline-block;
            width: 200px;
            padding: 5px;
            background-color: #31F794;
         }
      </style>
   </head>
   <body>
      <h1>Descending opacity</h1>

      <div>This is a text</div>
      <div>This is a text</div>
      <div>This is a text</div>
      <div>This is a text</div>
      <div>This is a text</div>
      <div>This is a text</div>
      <div>This is a text</div>
      <div>This is a text</div>

      <script src="../js/jquery-1.11.3.min.js"></script>
      <script>
         $('div').css({
            margin: '1em',
            color: '#1933FF',
            opacity: function (index, currentValue) {
               return 1 - ((index % 10) / 10);
            }
         });
      </script>
   </body>
</html>
